//
//  ZGNavTitleView.m
//  NewBee
//
//  Created by leergou on 16/8/20.
//  Copyright © 2016年 WhiteHouse. All rights reserved.
//

#import "ZGNavTitleView.h"
#define kMargin 5

@interface ZGNavTitleView ()

@property (nonatomic, strong) UILabel *smallLabel;

@property (nonatomic, strong) UILabel *bigLabel;

@property (nonatomic, strong) UIImageView *arrowImageView;


@end

@implementation ZGNavTitleView

- (instancetype)init{
    
    if (self = [super init]) {
        
        [self setupUI];
    }
    return self;
}

#pragma mark - 按钮点击 -
- (void)buttonClick:(UIButton *)sender{
    
    NSLog(@"配送按钮点击了");
    
}

#pragma mark - setupUI -

- (void)setupUI{
    
    NSLog(@"%@",NSStringFromCGRect(self.frame));
    
    [self addSubview:self.smallLabel];
    [self addSubview:self.bigLabel];
    [self addSubview:self.arrowImageView];

}

#pragma mark - 布局子控件 -
- (void)layoutSubviews{
    [super layoutSubviews];
    [self.smallLabel sizeToFit];
    [self.bigLabel sizeToFit];
    [self.arrowImageView sizeToFit];
    
    CGFloat height = self.frame.size.height;
    
    CGSize smallLabelSize = self.smallLabel.frame.size;
    CGSize bigLabelSize = self.bigLabel.frame.size;
    CGSize arrowButtonSize = self.arrowImageView.frame.size;
    
    self.smallLabel.frame = CGRectMake(0, (height - smallLabelSize.height) * 0.5, smallLabelSize.width, smallLabelSize.height);
    
    self.bigLabel.frame = CGRectMake(smallLabelSize.width + kMargin, (height - bigLabelSize.height) * 0.5, bigLabelSize.width, bigLabelSize.height);
    
    self.arrowImageView.frame = CGRectMake(smallLabelSize.width + bigLabelSize.width + 2 * kMargin, (height - arrowButtonSize.height) * 0.5, arrowButtonSize.width, arrowButtonSize.height);
    
}

#pragma mark - lazy -
- (UILabel *)smallLabel{
    if (!_smallLabel) {
        _smallLabel = [[UILabel alloc] init];
         _smallLabel.text = @"配送至";
        _smallLabel.font = [UIFont systemFontOfSize:10];
//        _smallLabel.backgroundColor = [UIColor yellowColor];
        [_smallLabel sizeToFit];
    }
    return _smallLabel;
}

- (UILabel *)bigLabel{
    if (!_bigLabel) {
        _bigLabel = [[UILabel alloc] init];
        _bigLabel.text = @"你在哪里";
        _bigLabel.font = [UIFont systemFontOfSize:15];
//        _bigLabel.backgroundColor = [UIColor greenColor];
        [_bigLabel sizeToFit];
    }
    return _bigLabel;
}

- (UIImageView *)arrowImageView{
    if (!_arrowImageView) {
        _arrowImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"allowBlack"]];
    }
    return _arrowImageView;
}

@end









